package com.rjwh.dingdong.client.mvp.model.impl;

import com.aishua.lib.task.AsResult;
import com.rjwh.dingdong.client.application.MyApplication;
import com.rjwh.dingdong.client.constant.LocalConstant;
import com.rjwh.dingdong.client.constant.NetConstant;
import com.rjwh.dingdong.client.mvp.BaseModel;
import com.rjwh.dingdong.client.mvp.BasePresenter;
import com.rjwh.dingdong.client.mvp.model.IMoreChangePasswordModel;
import com.rjwh.dingdong.client.network.HttpWebService;
import com.rjwh.dingdong.client.network.HttpWebServiceCallBack;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Kay
 * @ClassName MoreChangePasswordModel
 * @Description
 * @date 2016-10-19
 * @history 2016-10-19 author: description:
 */

public class MoreChangePasswordModel extends BaseModel implements IMoreChangePasswordModel, HttpWebServiceCallBack {

    public MoreChangePasswordModel(BasePresenter basePresenter) {
        super(basePresenter);
    }

    @Override
    public void doUpdatePwd(String oldpwd, String newpwd) {
        Map<String, String> params = new HashMap<>();
        params.put("userid", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.getInstance(), LocalConstant.SP_USERID));
        params.put("oldpwd", oldpwd);
        params.put("newpwd", newpwd);
        HttpWebService.getDataFromServer(NetConstant.UPDATEPWD, params, true, this);
    }

    @Override
    public void onServerDataAcquired(int businessType, AsResult mAsResult, boolean isRefresh) {
        if (getBasePresenter() != null) {
            getBasePresenter().onServerDataAcquired(businessType, mAsResult, isRefresh);
        }
    }
}
